package com.ruoyi.cmenonmetal.service.impl;

import com.ruoyi.cmenonmetal.domain.ZsPostProcess;
import com.ruoyi.cmenonmetal.mapper.ZsPostProcessMapper;
import com.ruoyi.cmenonmetal.service.IZsPostProcessService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * postprocessService业务层处理
 * 
 * @author zousong
 * @date 2022-02-23
 */
@Service
public class ZsPostProcessServiceImpl implements IZsPostProcessService 
{
    @Autowired
    private ZsPostProcessMapper zsPostProcessMapper;

    /**
     * 查询postprocess
     * 
     * @param id postprocess主键
     * @return postprocess
     */
    @Override
    public ZsPostProcess selectZsPostProcessById(Long id)
    {
        return zsPostProcessMapper.selectZsPostProcessById(id);
    }

    /**
     * 查询postprocess列表
     * 
     * @param zsPostProcess postprocess
     * @return postprocess
     */
    @Override
    public List<ZsPostProcess> selectZsPostProcessList(ZsPostProcess zsPostProcess)
    {
        return zsPostProcessMapper.selectZsPostProcessList(zsPostProcess);
    }

    /**
     * 新增postprocess
     * 
     * @param zsPostProcess postprocess
     * @return 结果
     */
    @Override
    public int insertZsPostProcess(ZsPostProcess zsPostProcess)
    {
        return zsPostProcessMapper.insertZsPostProcess(zsPostProcess);
    }

    /**
     * 修改postprocess
     * 
     * @param zsPostProcess postprocess
     * @return 结果
     */
    @Override
    public int updateZsPostProcess(ZsPostProcess zsPostProcess)
    {
        if(zsPostProcess.getOverTime()!=null) {
            long time = DateUtils.zxgetDatePoor(zsPostProcess.getOverTime(), zsPostProcess.getStartTime());
            zsPostProcess.setPostProcessTime(time);
        }else {
            long time1=0;
            zsPostProcess.setPostProcessTime(time1);

        }
        return zsPostProcessMapper.updateZsPostProcess(zsPostProcess);
    }

    /**
     * 批量删除postprocess
     * 
     * @param ids 需要删除的postprocess主键
     * @return 结果
     */
    @Override
    public int deleteZsPostProcessByIds(Long[] ids)
    {
        return zsPostProcessMapper.deleteZsPostProcessByIds(ids);
    }

    /**
     * 删除postprocess信息
     * 
     * @param id postprocess主键
     * @return 结果
     */
    @Override
    public int deleteZsPostProcessById(Long id)
    {
        return zsPostProcessMapper.deleteZsPostProcessById(id);
    }
}
